package com.netease.Dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.netease.jichu.Product;
/*private int id;
	private int price;//当前价格
	private String title;//标题
	private String image;//图片，此处为地址blob
	private String summary;//摘要
	private String detail;//全文
	private boolean isBuy;
	private boolean isSell;
 * */
public interface ProductDao {
	@Results({
		@Result(property="id",column="id"),
		@Result(property="title",column="title"),
		@Result(property="summary",column="abstract"),
		@Result(property="image",column="icon"),
		@Result(property="detail",column="text"),
		@Result(property="price",column="price")
	})
	//增加商品
	@Insert("insert into content(title,abstract,icon,text,price)values(#{title},#{summary},#{image},#{detail},#{price}) ")
	public void insertProduct(Product pro);
	@Results({
		@Result(property="id",column="id"),
		@Result(property="title",column="title"),
		@Result(property="summary",column="abstract"),
		@Result(property="image",column="icon"),
		@Result(property="detail",column="text"),
		@Result(property="price",column="price")
	})
	@Update("update content set title=#{title},abstract=#{summary},icon=#{image},text=#{detail},price=#{price} where id=#{id}")
	public void update(Product product);
	@Results({
		@Result(property="id",column="id"),
		@Result(property="title",column="title"),
		@Result(property="summary",column="abstract"),
		@Result(property="image",column="icon"),
		@Result(property="detail",column="text"),
		@Result(property="price",column="price")
	})
	//得到商品所有信息
	@Select("select * from content")
	public List<Product> productAll();
	@Results({
		@Result(property="id",column="id"),
		@Result(property="title",column="title"),
		@Result(property="summary",column="abstract"),
		@Result(property="image",column="icon"),
		@Result(property="detail",column="text"),
		@Result(property="price",column="price")
	})
	//根据id得到商品信息
	@Select("select * from content where id=#{id}")
	public Product getproduct(int id);
	@Results({
		@Result(property="id",column="id")})
	@Delete("delete from content where id=#{id}")
	public void deleteProduct(int id);
//	@Results({
//		@Result(property="id",column="id")})
//	@Select("select contentId from trx ,content where content.id=contentId")
//	public void set(Product product);
}
